package com.gts.sofa.config;

import com.gts.sofa.dao.BookDao;
import com.gts.sofa.interceptor.SourceAccessInterceptor;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 子容器
 * SpringMVC只扫描Controller
 * 必须设置useDefaultFilters=false 必须禁用默认的过滤规则
 *  includeFilters 意思是扫描的时候只扫描某些类型，根据注解来扫描，扫描那些用@Controller注解的类，并且禁用掉默认的。
 */
@ComponentScan(value = "com.gts.sofa",includeFilters =
        {@ComponentScan.Filter(type= FilterType.ANNOTATION,classes = {Controller.class}),
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookDao.class})} //根据类型来选择BookDao以及他的子类实现类都会加到容器里面的
        ,useDefaultFilters = false)
@EnableWebMvc
public class AppConfig extends WebMvcConfigurerAdapter {

    //定制视图解析器 这里配置的路径不是resource下面的，是web目录下面的
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/views/",".jsp");



    }



}
